package com.guli.mall.member.controller;

import java.util.Arrays;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.ApiOperation;

import com.guli.mall.member.entity.MemberCollectSubjectEntity;
import com.guli.mall.member.service.MemberCollectSubjectService;
import com.guli.common.utils.PageUtils;
import com.guli.common.utils.R;


/**
 * 会员收藏的专题活动
 *
 * @author 罗俊华
 * @email 1007052116@qq.com
 * @date 2020-10-18 18:44:16
 */
@RestController
@RequestMapping("member/membercollectsubject")
public class MemberCollectSubjectController {
    @Autowired
    private MemberCollectSubjectService memberCollectSubjectService;


    @GetMapping("/list/{currentPage}/{size}")
    @ApiOperation("根据当前页和每页显示的记录数来获取memberCollectSubject分页列表")
    public R list(@PathVariable("currentPage") Integer currentPage, @PathVariable("size") Integer size,@RequestParam Map<String, Object> params) {
        PageUtils<MemberCollectSubjectEntity> page = memberCollectSubjectService.queryPage(currentPage,size,params);

        return R.ok().put("page", page);
    }



    @GetMapping("/info/{id}")
    @ApiOperation("根据id获取MemberCollectSubject")
    public R info(@PathVariable("id") Long id) {
            MemberCollectSubjectEntity memberCollectSubject = memberCollectSubjectService.getById(id);

        return R.ok().put("memberCollectSubject", memberCollectSubject);
    }

    @PostMapping("/save")
    @ApiOperation("插入MemberCollectSubject")
    public R save(@RequestBody MemberCollectSubjectEntity memberCollectSubject) {
            memberCollectSubjectService.save(memberCollectSubject);

        return R.ok();
    }

    @PostMapping("/update")
    @ApiOperation("根据id更新MemberCollectSubject")
    public R update(@RequestBody MemberCollectSubjectEntity memberCollectSubject) {
            memberCollectSubjectService.updateById(memberCollectSubject);

        return R.ok();
    }

    @PutMapping("/deleteBatch")
    @ApiOperation("根据id批量删除MemberCollectSubject")
    public R delete(@RequestBody Long[] ids) {
            memberCollectSubjectService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
